package br.com.smanager.bo.common;

import java.util.List;

import br.com.smanager.dao.common.DataAccessObject;
import br.com.smanager.vo.common.ValueObject;

public class BusinessObject implements IBO {
	
	private DataAccessObject dao = null;
	
	protected void setDao(DataAccessObject dao) {
		if (getDao() == null) {
			this.dao = dao;
		}
	}
	
	protected DataAccessObject getDao() {
		return this.dao;
	}

	protected boolean validate(ValueObject valueObject) {
		return false;
	}

	@Override
	public boolean insert(ValueObject valueObject) {		
		if (! validate(valueObject)) {
			return false;
		} else {
			return dao.insert(valueObject);
		}
	}

	@Override
	public boolean update(ValueObject valueObject) {		
		if (! validate(valueObject)) {
			return false;
		} else {
			return dao.update(valueObject);
		}
	}

	@Override
	public boolean delete(ValueObject valueObject) {
		return dao.delete(valueObject);
	}

	@Override
	public boolean delete(int id) {
		return dao.delete(id);
	}

	@Override
	public ValueObject returnById(int id) {
		return dao.returnById(id);
	}
	
	@Override
	public List<ValueObject> returnAll() {
		return dao.returnAll();
	}

}